/***************************************************************
 *
 * (c) 2008 Markus Dittrich 
 *
 * This program is free software; you can redistribute it 
 * and/or modify it under the terms of the GNU General Public 
 * License Version 3 as published by the Free Software Foundation. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License Version 3 for more details.
 *
 * You should have received a copy of the GNU General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA 02111-1307, USA.
 *
 ****************************************************************/

#ifndef CANVASTODATAMAP_H 
#define CANVASTODATAMAP_H

/* boost includes */
#include <boost/shared_ptr.hpp>
#include <boost/multi_array.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/utility.hpp>

/* STL includes */
#include <vector>

/* Qt includes */
#include <QPoint>
#include <QString>


/*****************************************************************
 * convenience typedefs
 * 
 * NOTE: Each DataPoint tuple stores the name of the data set
 * and the data row that provides the particular data point 
 * stored in the canvas map.
 *****************************************************************/
typedef boost::tuple<QString, int> DataPoint;
typedef boost::multi_array<DataPoint,2> CanvasMap;


/**************************************************************
 * 
 * CanvasToDataMap keeps track of which pixels on the canvas
 * come from which data set and what data row. This is needed
 * to provide fast retrieval and display of the addtional
 * data info popup windows
 * 
 *************************************************************/
class CanvasToDataMap : public boost::noncopyable
{

public:

  explicit CanvasToDataMap(int width, int height);
 
  void clear();
  void insert(const QPoint* dataPoints, int numItems,
      const QString& dataName);
  const DataPoint& retrieve(int xPos, int yPos) const;


private:

  /* main 2D canvas map */
  CanvasMap PointStore_;

  /* dimensions of canvas map */
  int Width_;
  int Height_;
};



/*****************************************************************
 * convenience typedef
 *****************************************************************/
typedef boost::shared_ptr<CanvasToDataMap> CanvasMapPtr;


#endif
